package cn.yuanqiao.archive.appManager.service.impl;

import cn.yuanqiao.archive.appManager.domain.SysSyConfig;
import cn.yuanqiao.archive.appManager.mapper.SysSyConfigMapper;
import cn.yuanqiao.archive.appManager.service.ISysSyConfigService;
import cn.yuanqiao.common.utils.SecurityUtils;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author zjj
 * @date 2023/8/4
 */
@Service
public class SysSyConfigServiceImpl implements ISysSyConfigService {
    @Autowired
    private SysSyConfigMapper sysSyConfigMapper;

    @Override
    @Transactional
    public void saveSysSyConfig(String roleName, String names,Integer type) {
        String tenantCode = SecurityUtils.getTenantCode();
        //先删除
        sysSyConfigMapper.delSysSyConfig(roleName,type,tenantCode);
        String [] nameList = names.split(",");
        for(String name:nameList){
            SysSyConfig config = new SysSyConfig();
            config.setName(name);
            config.setRoleName(roleName);
            config.setTenantCode(tenantCode);
            config.setType(type);
            sysSyConfigMapper.insertSysSyConfig(config);
        }
    }

    @Override
    public List<SysSyConfig> selectSysSyConfig(String roleName, Integer type) {
        String tenantCode = SecurityUtils.getTenantCode();
        return sysSyConfigMapper.selectSysSyConfig(roleName,type,tenantCode);
    }

    @Override
    public JSONArray getSyConfigName() {
        JSONArray array = new JSONArray();
        JSONObject WDJY = new JSONObject();
        WDJY.put("name","我的借阅");
        WDJY.put("value","WDJY");
        WDJY.put("type",1);
        array.add(WDJY);
        JSONObject WDSPJD = new JSONObject();
        WDSPJD.put("name","我的审批进度");
        WDSPJD.put("value","WDSPJD");
        WDSPJD.put("type",1);
        array.add(WDSPJD);
        JSONObject GLDAGDQKDB = new JSONObject();
        GLDAGDQKDB.put("name","各类档案归档情况对比(年)");
        GLDAGDQKDB.put("value","GLDAGDQKDB");
        GLDAGDQKDB.put("type",1);
        array.add(GLDAGDQKDB);
        JSONObject TZGG = new JSONObject();
        TZGG.put("name","通知公告");
        TZGG.put("value","TZGG");
        TZGG.put("type",1);
        array.add(TZGG);
        JSONObject DBJY = new JSONObject();
        DBJY.put("name","待办借阅");
        DBJY.put("value","DBJY");
        DBJY.put("type",1);
        array.add(DBJY);
        JSONObject DBGD = new JSONObject();
        DBGD.put("name","待办归档");
        DBGD.put("value","DBGD");
        DBGD.put("type",1);
        array.add(DBGD);
        JSONObject MRJYL = new JSONObject();
        MRJYL.put("name","每日借阅量");
        MRJYL.put("value","MRJYL");
        MRJYL.put("type",1);
        array.add(MRJYL);
        JSONObject KCTJ = new JSONObject();
        KCTJ.put("name","库存统计");
        KCTJ.put("value","KCTJ");
        KCTJ.put("type",1);
        array.add(KCTJ);
        JSONObject MRFWL = new JSONObject();
        MRFWL.put("name","每日访问量");
        MRFWL.put("value","MRFWL");
        MRFWL.put("type",1);
        array.add(MRFWL);
        JSONObject YGDLB = new JSONObject();
        YGDLB.put("name","预归档列表");
        YGDLB.put("value","YGDLB");
        YGDLB.put("type",1);
        array.add(YGDLB);
        JSONObject CPXX = new JSONObject();
        CPXX.put("name","磁盘信息");
        CPXX.put("value","CPXX");
        CPXX.put("type",1);
        array.add(CPXX);


        JSONObject DAZL = new JSONObject();
        DAZL.put("name","档案整理");
        DAZL.put("value","DAZL");
        DAZL.put("type",2);
        array.add(DAZL);
        JSONObject JYGL = new JSONObject();
        JYGL.put("name","借阅记录");
        JYGL.put("value","JYGL");
        JYGL.put("type",2);
        array.add(JYGL);
        JSONObject MLJS = new JSONObject();
        MLJS.put("name","目录检索");
        MLJS.put("value","MLJS");
        MLJS.put("type",2);
        array.add(MLJS);
        JSONObject LYTJ = new JSONObject();
        LYTJ.put("name","利用统计");
        LYTJ.put("value","LYTJ");
        LYTJ.put("type",2);
        array.add(LYTJ);
        JSONObject DAJS = new JSONObject();
        DAJS.put("name","档案接收");
        DAJS.put("value","DAJS");
        DAJS.put("type",2);
        array.add(DAJS);
        JSONObject QWJS = new JSONObject();
        QWJS.put("name","全文检索");
        QWJS.put("value","QWJS");
        QWJS.put("type",2);
        array.add(QWJS);
//        JSONObject GXPT = new JSONObject();
//        QWJS.put("name","共享平台");
//        QWJS.put("value","GXPT");
//        QWJS.put("type",2);
//        array.add(GXPT);
//        JSONObject CQBC = new JSONObject();
//        CQBC.put("name","长期保存");
//        CQBC.put("value","CQBC");
//        CQBC.put("type",2);
//        array.add(CQBC);
//        JSONObject JSC = new JSONObject();
//        JSC.put("name","驾驶舱");
//        JSC.put("value","JSC");
//        JSC.put("type",2);
//        array.add(JSC);


        JSONObject DSH = new JSONObject();
        DSH.put("name","待审核");
        DSH.put("value","DSH");
        DSH.put("type",3);
        array.add(DSH);
        JSONObject DGH = new JSONObject();
        DGH.put("name","申请中");
        DGH.put("value","DGH");
        DGH.put("type",3);
        array.add(DGH);
        JSONObject JYZ = new JSONObject();
        JYZ.put("name","借阅中");
        JYZ.put("value","JYZ");
        JYZ.put("type",3);
        array.add(JYZ);
        JSONObject YYQ = new JSONObject();
        YYQ.put("name","已逾期");
        YYQ.put("value","YYQ");
        YYQ.put("type",3);
        array.add(YYQ);
        JSONObject DZJ = new JSONObject();
        DZJ.put("name","待组卷");
        DZJ.put("value","DZJ");
        DZJ.put("type",3);
        array.add(DZJ);
        JSONObject DJS = new JSONObject();
        DZJ.put("name","待接收");
        DZJ.put("value","DJS");
        DZJ.put("type",3);
        array.add(DJS);

        JSONObject WDDY1 = new JSONObject();
        WDDY1.put("name","我的订阅");
        WDDY1.put("value","WDDY");
        WDDY1.put("type",3);
        array.add(WDDY1);
        JSONObject WDXZ1 = new JSONObject();
        WDXZ1.put("name","我的下载");
        WDXZ1.put("value","WDXZ");
        WDXZ1.put("type",3);
        array.add(WDXZ1);
        JSONObject WDSC1 = new JSONObject();
        WDSC1.put("name","我的收藏");
        WDSC1.put("value","WDSC");
        WDSC1.put("type",3);
        array.add(WDSC1);


        JSONObject WDDY = new JSONObject();
        WDDY.put("name","我的订阅");
        WDDY.put("value","WDDY");
        WDDY.put("type",4);
        array.add(WDDY);
        JSONObject WDXZ = new JSONObject();
        WDXZ.put("name","我的下载");
        WDXZ.put("value","WDXZ");
        WDXZ.put("type",4);
        array.add(WDXZ);
        JSONObject WDSC = new JSONObject();
        WDSC.put("name","我的收藏");
        WDSC.put("value","WDSC");
        WDSC.put("type",4);
        array.add(WDSC);
        return array;
    }
}
